#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
struct STU
{
	int age;
	char name[20];
	int height;
};
int compar_name(const void* p1, const void* p2)
{
	char* p3 = ((struct STU*)p1)->name;
	char* p4 = ((struct STU*)p2)->name;
	if (strcmp(p3, p4) > 0)
	{
		return 1;
	}
	else
	{
		return -1;
	}



}

void my_qsort(void* p, size_t num, size_t size, int compar(const void* p1, const void* p2))
{
	for (int i = 0;i < num - 1;i++)
	{
		char* p1 = (char*)p+i*size;
		char* p2 = (char*)p + (i+1) * size;
		if (compar(p1, p2) > 0)
		{

			for (int i = 0;i < size;i++)
			{
				char tmp = *p1;
				*p1 = *p2;
				*p2 = tmp;
				p1++;
				p2++;

			}
		}
	}

}


int main()
{
	struct STU arr[] = { {20,"zghdf",10},{60,"bgb",6},{54,"ppt",9} };
	my_qsort(arr, 3, sizeof(arr[0]), compar_name);
	return 0;
}